import {getItemBalance} from '~/server/database/repositories/itemOperation'
export default defineEventHandler( async(context) => {
  try{
    const paramData = getQuery(context) || {}
    const { happened_after, happened_before} = paramData
    if(!happened_after || !happened_before){
      return sendError(context,createError({
        statusCode: 400,
        statusMessage: '参数错误!',
      }))
    }
    const balance = await getItemBalance({happened_after,happened_before} as ItemListDateParam)
    return {
      resource:balance
      }
  }
  catch(error){
    return sendError(context, createError({
      statusCode: 400,
      statusMessage: '获取数据失败!',
    }))
  }
})